﻿using System.Threading.Tasks;
using NUnit.Framework;
using Vk.Authorization;

namespace UnitTests
{
    [TestFixture]
    public class AuthorizationTests
    {
        private const int AppId = -1;
        private const string Login = "LOGIN";
        private const string Password = "PASS";

        [Test]
        [TestCase(0, ExpectedResult = false)]     
        [TestCase(AppId, ExpectedResult = true)]
        public async Task<bool> HiddenAuthTest(int appId)
        {
            var hidden = new HiddenAuth(appId);
            hidden.AuthSuccess += (sender, args) => Assert.That(args.Session.IsValid());
            return await hidden.AuthAsync(Login, Password);
        }

        [Test]
        [TestCase(0, ExpectedResult = false)]
        [TestCase(AppId, ExpectedResult = true)]
        public async Task<bool> HiddenAuthTestWithPermissions(int appId)
        {
            var hidden = new HiddenAuth(appId, new ApiAccessPermissions().Friends().Audio());
            hidden.AuthSuccess += (sender, args) => Assert.That(args.Session.IsValid());
            return await hidden.AuthAsync(Login, Password);
        }
    }
}
